Utility functions for writing to the MSP430 internal flash memory. More...
#include "hal.h"#include "hal_flash_write.h"Functions | |
| signed int | getSegmentSize (unsigned int segment) |
| signed int | printInformationMemorySegment (unsigned int segment) |
| void | printInformationMemory () |
| signed char | informationMemorySegmentIsErased (unsigned int segment) |
| signed int | eraseInformationMemorySegment (unsigned int segment) |
| signed int | save (unsigned int segment, unsigned int offset, char data) |
| void | printResetReason () |
| __ramfunc signed int | writeFlashSegment (unsigned int segment, char *dataToWrite, unsigned int numBytes) |
Variables | |
| unsigned long | mclk |
| unsigned long | smclk |
Utility functions for writing to the MSP430 internal flash memory.
MSP430 Flash memory is divided into program memory & information memory.
Program Memory: Program memory must be erased in segments, but programmed in blocks. On the MSP430F2xx each segment is 512B and each block is 64B. MSP430F248 Program Flash from 0xFFFF to 0x4000 (48kB) in 512B segments, each divided into eight 64B blocks MSP430F247 Program Flash from 0xFFFF to 0x8000 (32kB) " " MSP430F2410 Program Flash from 0xFFFF to 0x2100 (56kB) " " Maximum address is 0xFFC0, higher than that is interrupt vectors.
Information Memory Information memory must be erased/programmed in segments. On the MSP430, Information Memory is from 0x10FF to 0x1000 (256B) in 64B segments Flash clock, fFTG must be from 257kHz to 476 kHz according to msp430F248 Datasheet, p69. Information Memory Segment A contains calibration data and shouldn't be touched. The state of the LOCKA bit is toggled when a 1 is written to it. Writing a 0 to LOCKA has no effect. This allows existing flash programming routines to be used unchanged.
| signed int eraseInformationMemorySegment | ( | unsigned int | segment | ) |
Erases a segment of information memory. Does not allow erasing segment A.
| segment | which information memory segment |
| signed int getSegmentSize | ( | unsigned int | segment | ) |
Private helper function to get the size of info mem or prog mem segments
| signed char informationMemorySegmentIsErased | ( | unsigned int | segment | ) |
Determines if a segment of flash is erased (all 0xFF)
| void printInformationMemory | ( | ) |
Displays the contents of all four information memory segments
| signed int printInformationMemorySegment | ( | unsigned int | segment | ) |
Displays the contents of an information memory segment, with labels every 0x10 bytes
| segment | which information memory segment, either one of the predefined information memory segments or program memory segments |
| signed int save | ( | unsigned int | segment, | |
| unsigned int | offset, | |||
| char | data | |||
| ) |
Writes a single byte to information memory.
| __ramfunc signed int writeFlashSegment | ( | unsigned int | segment, | |
| char * | dataToWrite, | |||
| unsigned int | numBytes | |||
| ) |
Writes sequential bytes to flash memory. Supports writing to info memory or program memory.
| segment | which flash memory segment to write to. Must be a predefined info mem segment (INFO_MEM_SEGMENT_B, INFO_MEM_SEGMENT_C, or INFO_MEM_SEGMENT_D) or prog mem segment | |
| dataToWrite | the data to write to flash | |
| numBytes | the numberOfBytes to write. Must be less than segment size: 64B for info mem or 512B for prog mem. |
| unsigned long mclk |
For total code + CONST size of 29k, (as of 1/28/10) flash up to 0x5669 is in use. time for segment erase = 4819/fFTG, or about 12mSec time for block program is about 1.73mSec per Block, so total per segment is approx. 15mSec. If writing entire 30kB firmware image (60segments) then total time is ~900mSec. Total time spent programming each block must be less than 4mSec. (i.e. don't include much stuff inbetween writing bytes)
1.6.3